import { useState } from 'react'

const App = () => {
    const [count, setCount] = useState(10)
    // 一个组件可以引入多个 useState
    // const [age, setAge] = useState(42);
    // const [fruit, setFruit] = useState('banana');
    // const [todos, setTodos] = useState([{ text: 'Learn Hooks' }]);

    const add = () => {
        setCount((prevCount) => {
            return prevCount + 1
        })
    }
    return (
        <div>
            <h1>useState - 计数器案例</h1>
            <button onClick={() => {
                setCount(count - 1)
            }}>-</button>
            {count}
            <button onClick={add}>+</button>
        </div>
    )
}

export default App